﻿// ParseLib - An open source library for natural language processing.
// Copyright (C) Kais Dukes, 2012. E-mail: kais@kaisdukes.com
// http://parselib.org

using System.Text;

namespace ParseLib.Text
{
    public static class DisplayName
    {
        public static string Of(object instance)
        {
            return Of(instance.GetType().Name);
        }

        public static string Of(string value)
        {
            var name = new StringBuilder();

            var length = value.Length;
            for (var i = 0; i < length; i++)
            {
                var ch = value[i];
                if (i > 0 && ch >= 'A' && ch <= 'Z')
                {
                    name.Append(' ');
                }
                name.Append(ch);
            }

            return name.ToString();
        }
    }
}
